﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace VISS.API.Users {

    /// <summary>
    /// This interface is used for VISS.VN
    /// Used this interface to implement operations on User table
    /// </summary>
    public interface IUser {

        /// <summary>
        /// Insert new User, also create other profiles for that user (GeneralProfile, UserContactInfo, ...)
        /// </summary>
        /// <param name="item">The UserEnt item.</param>
        /// <param name="pItem">The UserGeneralProfileEnt item(can be null).</param>
        /// <param name="cItem">The UserContactInfoEnt item(can be null).</param>
        /// <returns>
        /// Return true if success, otherwise return false
        /// </returns>
        bool Insert(UserEnt item, UserGeneralProfileEnt pItem, UserContactInfoEnt cItem);

        /// <summary>
        /// Update email of User
        /// </summary>
        /// <param name="item">UserEnt</param>
        /// <returns>
        /// Return true if success, otherwise return false
        /// </returns>
        bool UpdateEmail(UserEnt item);
        /// <summary>
        /// Update email of User
        /// </summary>
        /// <param name="userKey">userKey</param>
        /// <param name="email">new email</param>
        /// <returns>
        /// Return true if success, otherwise return false
        /// </returns>
        bool UpdateEmail(string userKey, string email);
        /// <summary>
        /// Update password of User
        /// </summary>
        /// <param name="item">UserEnt</param>
        /// <returns>
        /// Return true if success, otherwise return false
        /// </returns>
        bool UpdatePassword(UserEnt item);
        /// <summary>
        /// Update password of User
        /// </summary>
        /// <param name="userKey">userKey</param>
        /// <param name="password">new password (unencrypted)</param>
        /// <returns>
        /// Return true if success, otherwise return false
        /// </returns>
        bool UpdatePassword(string userKey, string password);
        /// <summary>
        /// Update short link of user
        /// </summary>
        /// <param name="item">UserEnt</param>
        /// <returns>Return true if success, otherwise return false</returns>
        bool UpdateSLink(UserEnt item);
        /// <summary>
        /// Update short link of user
        /// </summary>
        /// <param name="userKey">userKey</param>
        /// <param name="sLink">new short link</param>
        /// <returns>
        /// Return true if success, otherwise return false
        /// </returns>
        bool UpdateSLink(string userKey, string sLink);
        /// <summary>
        /// Updates the short link expired date.
        /// </summary>
        /// <param name="item">The UserEnt item.</param>
        /// <returns>
        /// Return true if success, otherwise return false
        /// </returns>
        bool UpdateSLinkExpiredDate(UserEnt item);
        /// <summary>
        /// Updates the short link expired date.
        /// </summary>
        /// <param name="userKey">The user key.</param>
        /// <param name="sLinkExpiredDate">The short link expired date.</param>
        /// <returns></returns>
        bool UpdateSLinkExpiredDate(string userKey, DateTime sLinkExpiredDate);
        /// <summary>
        /// Updates the short link and short link expired date.
        /// </summary>
        /// <param name="item">The UserEnt item.</param>
        /// <returns>
        /// Return true if success, otherwise return false
        /// </returns>
        bool UpdateSLinkAndSLinkExpiredDate(UserEnt item);
        /// <summary>
        /// Updates the short link and short link expired date.
        /// </summary>
        /// <param name="userKey">The user key.</param>
        /// <param name="sLink">The short link.</param>
        /// <param name="sLinkExpiredDate">The short link expired date.</param>
        /// <returns>
        /// Return true if success, otherwise return false
        /// </returns>
        bool UpdateSLinkAndSLinkExpiredDate(string userKey, string sLink, DateTime sLinkExpiredDate);
        /// <summary>
        /// Updates the status.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns>
        /// Return true if success, otherwise return false
        /// </returns>
        bool UpdateStatus(UserEnt item);
        /// <summary>
        /// Updates the status.
        /// </summary>
        /// <param name="userKey">The user key.</param>
        /// <param name="status">The status.</param>
        /// <returns>
        /// Return true if success, otherwise return false
        /// </returns>
        bool UpdateStatus(string userKey, EUserStatus status);

        /// <summary>
        /// Hides the user from another users.
        /// </summary>
        /// <param name="userKey">The user key.</param>
        /// <returns>
        /// Return true if success, otherwise return false
        /// </returns>
        bool Hide(string userKey);
        /// <summary>
        /// Remove hide status from the user.
        /// </summary>
        /// <param name="userKey">The user key.</param>
        /// <returns>Return true if success, otherwise return false</returns>
        bool UnHide(string userKey);
        /// <summary>
        /// Gets the by user key.
        /// </summary>
        /// <param name="userKey">The user key.</param>
        /// <returns>return UserEnt if exists, otherwise return null</returns>
        UserEnt GetByUserKey(string userKey);

        /// <summary>
        /// Gets the by email.
        /// </summary>
        /// <param name="email">The email.</param>
        /// <returns></returns>
        UserEnt GetUserByEmail(string email);

        /// <summary>
        /// Resets the password.
        /// </summary>
        /// <param name="userKey">The user key.</param>
        /// <param name="password">The password.</param>
        /// <returns>Return true if success, otherwise return false</returns>
        bool ResetPassword(string userKey, out string password);

        /// <summary>
        /// Logins by email.
        /// </summary>
        /// <param name="email">The email.</param>
        /// <param name="password">The password.</param>
        /// <param name="item">output the UserEnt item if login info exists</param>
        /// <returns>return EUserLoginResult</returns>
        EUserLoginResult Login(string email, string password, out UserEnt item);
        /// <summary>
        /// Logins by OpenID
        /// </summary>
        /// <param name="email">The email.</param>
        /// <param name="item">output the UserEnt item if login info exists.</param>
        /// <returns>return EUserLoginResult</returns>
        EUserLoginResult OpenIDLogin(string email, out UserEnt item);

        /// <summary>
        /// Checks the email existed in User table.
        /// </summary>
        /// <param name="email">The email.</param>
        /// <returns>Return true if existed, otherwise return false</returns>
        ECheckEmailResult CheckEmailExisted(string email);
    }
}
